gcloud の --format オプション
from Cloud Logging
format オプションは Cloud Logging 固有でなくて gcloud 全体共通のもの
gcloud  |  Cloud SDK  |  Google Cloud
いろいろ書ける
--format=NAME[ATTRIBUTES](PROJECTION)
gcloud topic formats  |  Cloud SDK  |  Google Cloud
gcloud topic projections  |  Cloud SDK  |  Google Cloud
Filtering and formatting fun with gcloud, GCP’s command line interface | Google Cloud Blog
例が多くて良い
デフォルトは yaml
--format=json(jsonPayload) は、json 形式で、jsonPayload 以下を取り出す
--format=csv(jsonPayload.field1,jsonPayload.field2,jsonPayload.field3)
csv 形式で jsonPayload 以下の3つのフィールドを取り出している
キーを指定して1エントリを1次元のcsvにすると扱い易い
--format=csv[no-heading](name) なんかすると別のコマンドの入力にしやすい
pretty な json 出力を ndjson にするには ... | jq -c '.[]'
全体で1つの array 外側を外す
-c で compact に(1行に)
projection
gcloud topic projections  |  Google Cloud CLI Documentation
format の中で出力を加工できる
$ gcloud config configurations list --format='tableno-heading(is_active.yesno(yes=*,no=''), name, properties.core.account, properties.core.project.yesno(no="(unset)"))'
.yesno(yes, no) で boolean や null 値を別の値にできる
#GoogleCloud #gcloud